// import { getList } from '@/api/system/notice'
import { mapGetters } from 'vuex'
import ECharts from 'vue-echarts/components/ECharts'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/pie'
import 'echarts/lib/chart/map'
import 'echarts/lib/chart/radar'
import 'echarts/lib/chart/scatter'
import 'echarts/lib/chart/effectScatter'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/polar'
import 'echarts/lib/component/geo'
import 'echarts/lib/component/legend'
import 'echarts/lib/component/title'
import 'echarts/lib/component/visualMap'
import 'echarts/lib/component/dataset'
import 'echarts/map/js/world'
import 'zrender/lib/svg/svg'
import { getList } from '@/api/cms/order'

export default {

  name: 'dashboard',
  components: {
    chart: ECharts
  },
  data() {
    return {

      barData: {
        xAxis: {
          type: 'category',
          data: []
        },
        yAxis: {
          type: 'value'
        },
        series: {
          data: [0, 0, 0, 0, 0, 0],
          type: 'bar'
        }
      },

      listQuery: {
        page: 1,
        limit: 20,
        userID: undefined,
        mobile: undefined,
        status: undefined,
        remark: undefined,
        startDate: undefined,
        endDate: undefined

      },
      sum: 0,
      rangeDate: undefined,
      total: 0,
      list: null,
      listLoading: true,
      selRow: {}
    }
  },
  computed: {
    ...mapGetters([
      'name'

    ])
  },
  created() {
    this.fetchData()
  },
  methods: {

    fetchData() {
      this.listLoading = true
      const queryData = this.listQuery
      if (this.rangeDate) {
        queryData['startDate'] = this.rangeDate[0]
        queryData['endDate'] = this.rangeDate[1]
      }
      getList(queryData).then(response => {
        this.list = response.data.records
        for (var i of this.list) {
          this.sum += i.price
          // console.log(this.barData.xAxis.data)
          // if(this.barData.xAxis.data.findIndex(target => target.sel === i.createTime)==-1)
          //   this.barData.xAxis.data.push(i.createTime)
          // else
          //   this.barData.series.data[0]
          i.content = JSON.parse(i.content)
          console.log(i.content)
        }
        this.listLoading = false
        this.total = response.data.total
        this.barData.series.data.push(this.total)
      })
    }

  }
}
